<template>
  <p>{{ name }}</p>
  <p @click="add">年龄加1</p>
</template>

<script>
import { onMounted, inject } from "vue";
export default {
  props: ["age", "fun"],
  //   props: {
  //     // name:String,
  //     age: Number,
  //     fun: Function,
  //   },
  emits: {
      fun:(age)=>age
  },
  setup(props, context) {
    const name = inject("name");
    const add = () => {
      let age = props.age + 1;
      context.emit("fun", age);
    };

    onMounted(() => {});
    return {
      add,
      props,
      name,
    };
  },
};
</script>

<style>
</style>